import 'package:flutter/material.dart';
import '../pages/search.dart';
import '../pages/list.dart';
import '../pages/videoplayer.dart';
import '../pages/videolistpage.dart';
import '../pages/audioplayer.dart';
import '../pages/recommendpage.dart';
import '../pages/singer.dart';
import '../pages/allsingers.dart';
import '../pages/albumpage.dart';
import '../pages/channeldetail.dart';
import '../pages/videoswiper.dart';

//配置路由
final routes = {
  '/mylist': (context) => MyList(),
  '/videolist': (context) => VideoList(),
  '/videoplayer': (context, {arguments}) => VideoPlayer(arguments: arguments),
  '/audioplayer': (context, {arguments}) => AudioPlayer(arguments: arguments),
  '/recommendpage': (context, {arguments}) =>
      RecommendPage(arguments: arguments),
  '/singer': (context, {arguments}) => Singer(arguments: arguments),
  '/allsingers': (context) => SideListViewMenu(),
  '/album': (context, {arguments}) => AlbumPage(arguments: arguments),
  '/chaneldetail': (context, {arguments}) =>
      ChannerDetail(arguments: arguments),
  '/videoswiper': (context, {arguments}) => VideoSwiper(arguments: arguments),
  '/search': (context) => Search(),
};

//固定写法
// ignore: top_level_function_literal_block
var onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  final String? name = settings.name;
  final Function pageContentBuilder = routes[name] as Function;
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
